package com.spaceobj.project.controller;

import cn.dev33.satoken.util.SaResult;
import com.spaceobj.common.core.utils.SourceToTargetUtils;
import com.spaceobj.project.dto.SysSourceTypeDto;
import com.spaceobj.project.pojo.SysSearchContent;
import com.spaceobj.project.pojo.SysSourceType;
import com.spaceobj.project.service.SysSearchContentService;
import com.spaceobj.project.service.SysSourceTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zhr_java@163.com
 * @date 2022/9/5 22:11
 */
@RestController(value = "sourceTypeController")
@RequestMapping(value = "sourceType", method = RequestMethod.POST)
public class SysSourceTypeController {

  @Autowired private SysSourceTypeService sysSourceTypeService;

  @PostMapping(value = "add")
  public SaResult add(SysSourceType sysSourceType) {
    return sysSourceTypeService.add(sysSourceType);
  }

  @PostMapping(value = "update")
  public SaResult update(SysSourceTypeDto sysSourceTypeDto) {
    SysSourceType sysSourceType = new SysSourceType();
    SourceToTargetUtils.copyNotNullProperties(sysSourceTypeDto,sysSourceType);
    return sysSourceTypeService.update(sysSourceType);
  }

  @PostMapping("list")
  public SaResult list(SysSourceType sysSourceType) {
    return sysSourceTypeService.list(sysSourceType);
  }

  @PostMapping(value = "findById")
  public SaResult findById(long id) {

    return sysSourceTypeService.findById(id);
  }
}
